import {Observable, Subject} from 'rxjs';
import {RSocket} from "rsocket-core";
import {Cancellable} from "rsocket-core/dist/RSocket";
import {Notify} from "./DAsgard";

export default interface IAsgard {
    // 连接
    connect(): Promise<RSocket>;
    // 断开连接
    disconnect(): void;
    // 错误处理
    onError(err:Error): void;

    //发送post请求 没有响应体
    post<Q>(path: string, data?: Q): Promise<void>

    //发送get请求 有响应体
    get<Q, B>(path: string, data?: Q): Promise<B>

    //订阅消息
    broadcast<Q, S>(path: string, data?: Q, initialRequestN?:number): Subject<S>

    //订阅广播消息
    notify<S extends {route:string,body:string}>(): Observable<Notify<S>>

    //认证
    auth(token:string): Promise<void>

    //取消认证
    unAuth(): Promise<void>

    setClientId(clientId:string): void

}
